package models;

import java.util.Calendar;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.Lob;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import play.db.jpa.Model;

@Entity
@Table(name = "Logs")
public class Log extends Model {

	// @ManyToOne
	// public Action action;

	@Column(name = "user_id")
	public Long userId;

	@Column(name = "artifact_id")
	public Long artifactId;

	@Column(name = "artifact_type")
	public String artifactType;

	public String description;

	public Calendar date;

	public Long projectId;

	@Lob
	public String userComment;

	// @ManyToOne
	// @JoinTable(name = "Logs_Projects", joinColumns = @JoinColumn(name =
	// "log_id"), inverseJoinColumns = @JoinColumn(name = "project_id"))
	// public Project project;

	// project logs
	public Log(Long userId, Long artifactId, String artifactType,
			String description, Long projectId, String userComment) {
		this.userId = userId;
		this.artifactId = artifactId;
		this.artifactType = artifactType;
		this.description = description;
		this.projectId = projectId;
		this.date = Calendar.getInstance();
		this.userComment = userComment;
	}

	// system logs
	public Log(Long userId, Long artifactId, String artifactType,
			String description, String userComment) {
		this.userId = userId;
		this.artifactId = artifactId;
		this.artifactType = artifactType;
		this.description = description;
		this.date = Calendar.getInstance();
		this.userComment = userComment;
	}

	// Logs done by the system
	public Log(Long artifactId, String artifactType, String description,
			Long projectId, String userComment) {

		this.artifactId = artifactId;
		this.artifactType = artifactType;
		this.description = description;
		this.projectId = projectId;
		this.date = Calendar.getInstance();
		this.userComment = userComment;
	}
}
